home *** CD-ROM | disk | FTP | other *** search
- /* Simple UNIX like cat on ATARI ST. Kees Lemmens; Juli 1992
-
- Also works with pipes like in "cat file | more"
-
- Any questions or suggestions about this program can be send to:
- lemmens@dv.twi.tudelft.nl
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "ux_misc.h"
-
- #define MAXLEN 1000
-
- void main(int argc,char *argv[])
- { FILE *in;
- char buffer[MAXLEN];
-
- if (argc >1 )
- { ux2dos(argv[1]); /* convert slashes */
- if ((in = fopen(argv[1],"r")) == NULL)
- { fputs("\nCan't open file\n",stderr);
- exit(1);
- }
- }
- else in = stdin;
-
- do
- { *buffer='\0';
- fgets(buffer,MAXLEN-1,in); /* save space for \n */
- if(strrchr(buffer,'\n') == NULL)
- strcat(buffer+strlen(buffer),"\n\0");
- fputs(buffer,stdout);
- } while(! feof(in));
- if (in != stdin) fclose(in);
- exit(0);
- }